package com.kuangstudy.thread.demo3;

/**
 * @author Losca
 * @date 2021/7/19 20:01
 */
public class Demo4{
    public static void main(String[] args) {
        Thread thread = new Thread(()->{
            for (int i = 0; i < 5; i++) {
                try {
                    Thread.sleep(1000);
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
            }
            System.out.println("=======");
        });
        Thread.State state = thread.getState();
        System.out.println(state);//new

        thread.start();//启动线程
        state = thread.getState();
        while (state != Thread.State.TERMINATED) {
            try {
                Thread.sleep(1000);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
            state = thread.getState();
            System.out.println(state);
        }


    }
}
/**
 * NEW
 * RUNNABLE
 * TIMED_WAITING
 * TIMED_WAITING
 * TIMED_WAITING
 * TIMED_WAITING
 * =======
 * TERMINATED
 */
